#include<iostream>
#include<vector>
using namespace std;
class Solution {
    string path;
    vector<string> ret;
    vector<string> map = { "abc", "def",  "ghi", "jkl",
                          "mno", "pqrs", "tuv", "wxyz" };

public:
    vector<string> letterCombinations(string nums) {
        if (nums.empty())
            return ret;
        dfs(nums, 0);
        return ret;
    }
    void dfs(string nums, int i) {
        if (path.size() == nums.size()) {
            ret.push_back(path);
            return;
        }

        int num = nums[i] - '0' - 2;
        for (int j = 0; j < map[num].size(); j++) {
            path.push_back(map[num][j]);
            dfs(nums, i + 1);
            path.pop_back();
        }
        // return;
    }
};